﻿@model VisaApp.Models.CauhoiModel
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestFromCauHoi"
    };
}

<script type="text/javascript">

    function completedAjaxRequestFromCauHoi(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {
            $(".fromcauhoi").html("");
            makeSuccessHighlightFromCauHoi("Cảm ơn bạn đã gởi câu hỏi đến chúng tôi .</br> Chúng tôi sẽ trả lời nhanh chóng cho quý khách nhanh chóng qua website và email .</br>  Chúc bạn có 1 ngày tốt đẹp");

        } else {
            makeErrorHighlightFromCauHoi(returnObj.Message);
        }

        return false;
    }

    function makeErrorHighlightFromCauHoi(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Lỗi: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-cauhoi");
        $highlight.delay(4000).fadeOut(500);

    }

    function makeSuccessHighlightFromCauHoi(messageStr) {
        var $highlight = $("<div style='padding:0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Thành công: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".fromcauhoi");
    }

    $(document).ready(function () {
        $(".rich-text").cleditor({ width: 430, height: 300, useCSS: true });
        onSelectlistCategoryCauhoi();
    });


    function onSelectlistCategoryCauhoi() {
        var ids = $("#selectKhuVucCauHoi").val();
        $("#regioncodeCauhoi").val(ids);
        $.getJSON("/Visa/AllQuocGiaByCateid/" + ids,
            function (carData) {
                var select = $("#selectProductCauhoi");
                select.empty();
                $.each(carData, function (index, itemData) {
                    select.append($('<option/>', {
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });
                var name = carData[0].Value;
                $("#visadencacnuoc").val(Value);
            });
    }

    function OnSelectProductCauhoi() {
        var txt = $("#selectProductCauhoi option:selected").val();
        $("#visadencacnuocCauhoi").val(txt);

    }

</script>
@using (Ajax.BeginForm("EmailGoiCauHoi", "News", null, ajaxOpts, new { enctype = "multipart/form-data", name = "frm_register-visa", id = "frm_register-visa" }))
{
    <!-- home text -->
    <div class="folder-content">
        <div style="display: inline-block">
            <div class="box-middle1 box-weather fl fromcauhoi">
                <div class="messageInfoSuccess">
                    <ul class="formreg">
                    <li class="warning-area-cauhoi"></li>
                    @Html.HiddenFor(model => model.regioncode, new { id = "regioncodeCauhoi" })
                     @Html.HiddenFor(model => model.QuocgiaID, new { id = "visadencacnuocCauhoi" })

                    <li><span class="left">Khu vực</span> <span class="right">
                        <select id="selectKhuVucCauHoi" onchange = "onSelectlistCategoryCauhoi()">
                            <option value="142">Châu Á</option>
                            <option value="150">Châu Âu</option>
                            <option value="009">Châu Đại Dương</option>
                            <option value="002">Châu Phi</option>
                            <option value="019">Bắc Mỹ</option>
                            <option value="300">Nam Mỹ</option>
                        </select>
                    </span></li>
                    <li><span class="left">Quốc gia</span> <span class="right">
                        <select id="selectProductCauhoi" class="selectProduct" onchange="OnSelectProductCauhoi()">
                        </select>
                    </span></li>
                     <li><span class="left">Tiêu đề <span class="namerequired">*</span></span> <span class="right">
                        @Html.TextBoxFor(model => model.Title, new { name = "Title", value = "", @class = "validate[required]", style = "width: 99%;" })
                    </span></li>
                    <li><span class="left">Họ tên <span class="namerequired">*</span></span> <span class="right">
                        @Html.TextBoxFor(model => model.Name, new { name = "UserName", value = "", @class = "validate[required]", style = "width: 99%;" })
                    </span></li>
                    <li><span class="left">Email <span class="namerequired">*</span></span> <span class="right">
                        @Html.TextBoxFor(model => model.Email, new { name = "Email", value = "", @class = "validate[required,custom[email]]", style = "width: 99%;" })
                    </span></li>
                    <li class="line"><span class="left">Nội dung <span class="namerequired">*</span></span> <span class="right">
                       @Html.TextAreaFor(model => model.Noidung, new { name = "NoiDung", @class = "txt_NoiDung rich-text", style = "width: 98%; height:148px;" })
                    </span></li>
                    <li class="line"><span class="left">
                        <input type="submit" style="border: 0;" class="btnsubmit2" value="Gởi câu hỏi" name=""></span>
                         <span class="right">
                            <br />
                            <span class="namerequired">Dấu * là thông tin bắt buộc nhập</span>
                        </span>
                    </li>
                </ul>
                </div>
            </div>
        </div>
    </div>
}